package com.mrdeer.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mrdeer.user.api.dto.tenant.AccountDTO;
import com.mrdeer.user.api.dto.tenant.AccountQueryDTO;
import com.mrdeer.user.api.entity.Account;
import com.mrdeer.user.api.entity.TenantAccount;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author ：xie jianchu
 * @date ：Created in 2020/9/7 0007 17:49
 */
@Repository
public interface AccountMapper extends BaseMapper<Account> {

    int selectAccountInTenantByMobile(@Param("tenantId") Long tenantId, @Param("mobile") String mobile);

    int selectAccountInTenantByName(@Param("tenantId") Long tenantId, @Param("username") String username);

    int selectAccountByMobile(@Param("mobile") String mobile);

    int selectAccountByName(@Param("username") String username);

    void deleteAccount(@Param("accountId") Long accountId);

    List<TenantAccount> selectNotAdmin(@Param("tenantId") Long tenantId, @Param("username") String usrname);

    boolean selectAccountByRole(@Param("tenantId") Long tenantId, @Param("tenantId") String roleCode);

    List<AccountDTO> selectAccountByPage(@Param("page") Page<AccountDTO> page,
                                         @Param("accountQuery") AccountQueryDTO accountQuery,
                                         @Param("sortBy") String sortBy,
                                         @Param("order") String order);

    List<Long> selectAccountByTenantId(@Param("tenantId") Long tenantId);

    /**
     * 根据租户ID查询账号的信息
     *
     * @param tenantId
     * @return
     */
    Account selectAccountInfoByTenantId(@Param("tenantId") Long tenantId);
}
